<?php

$config = [
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'MeLYJk4dSdTH-PZyr4U3RPQ0IoPe-Kf6',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
                'text/json' => 'yii\web\JsonParser',
            ],
        ],
        // 统计分析数据库链接
        'odb' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=10.5.23.75;dbname=myscrm_olap',
            'username' => 'sa',
            'password' => '95938',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        // 配置库数据库链接
        'cdb' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=contract.mysql.rds.aliyuncs.com;dbname=contract_yk_config',
            'username' => 'contract',
            'password' => 'Contract2018@',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        // 合同管理数据库链接
        'contractDB' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=contract.mysql.rds.aliyuncs.com;dbname=contract_yk',
            'username' => 'contract',
            'password' => 'Contract2018@',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        // 代理版配置库数据库链接
        'dlcdb' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=contract.mysql.rds.aliyuncs.com;dbname=contract_yk_config',
            'username' => 'contract',
            'password' => 'Contract2018@',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        // 租户库数据库链接（正式发布时删除）
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=contract.mysql.rds.aliyuncs.com;dbname=contract_yk_config',
            'username' => 'contract',
            'password' => 'Contract2018@',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        // 日志库数据库链接
        'ldb' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=10.5.23.75;dbname=myscrm_logs_dev',
            'username' => 'sa',
            'password' => '95938',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        //日志库
        'common_log' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=127.0.0.1;dbname=contract_common',
            'username' => 'root',
            'password' => 'Contract2018@',
            'charset' => 'utf8',
            'tablePrefix' => ''
        ],
        'cache' => [
            'class' => 'yii\caching\MemCache',
            'useMemcached' => true,
            'servers' => [
                [
                    'host' => '127.0.0.1',
                    'port' => 11211,
                    'weight' => 100,
                ],
            ],
        ],
        'user' => [
            'identityClass' => 'mybackend\models\MyAdminIdentity',
            'enableAutoLogin' => false,
        ],
        'log' => [
            'traceLevel' => 0,//YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                    'maxLogFiles' => 20,
                    'logVars' => [],    //控制哪些全局变量信息会自动写入log
                ],
                [
                    'class' => 'yii\log\FileTarget',//
                    'levels' => ['info'],
                    'maxLogFiles' => 20,
                    'categories' => ['operate'],
                    'logFile' => '@app/runtime/logs/operate/log.log',
                    'maxFileSize' => 1024 * 2,
                    'logVars' => [],    //控制哪些全局变量信息会自动写入log
                ],
                [
                    'class' => 'yii\log\FileTarget',//
                    'levels' => ['info'],
                    'maxLogFiles' => 20,
                    'categories' => ['performance'],
                    'logFile' => '@app/runtime/logs/performance/log.log',
                    'maxFileSize' => 1024 * 2,
                    'logVars' => [],    //控制哪些全局变量信息会自动写入log
                ],
                [
                    'class' => 'yii\log\FileTarget',//
                    'levels' => ['info'],
                    'maxLogFiles' => 20,
                    'categories' => ['channel'],
                    'logFile' => '@app/runtime/logs/channel/log.log',
                    'maxFileSize' => 1024 * 2,
                    'logVars' => [],    //控制哪些全局变量信息会自动写入log
                ],
                [
                    'class' => 'yii\log\FileTarget',//
                    'levels' => ['info','error'],
                    'maxLogFiles' => 20,
                    'categories' => ['carry_over_log'],
                    'logFile' => '@app/runtime/logs/carry_over_log/carry_over_log.log',
                    'maxFileSize' => 1024 * 2,
                    'logVars' => [],    //控制哪些全局变量信息会自动写入log
                ],
                [
                    'class' => 'yii\log\FileTarget',//
                    'levels' => ['info','error'],
                    'maxLogFiles' => 20,
                    'categories' => ['delivery_order_product_info'],
                    'logFile' => '@app/runtime/logs/carry_over_log/delivery_order_product_info.log',
                    'maxFileSize' => 1024 * 2,
                    'logVars' => [],    //控制哪些全局变量信息会自动写入log
                ]
            ],
        ],
        'session' => [
            'class' => 'yii\web\DbSession',
            'db' => 'cdb',
            'sessionTable' => 'myscrm_session',
            'timeout' => 7200
        ],
        //'session' => array (
        //    'class'=> 'yii\web\CacheSession',
        //    'timeout' => 14400//minute?
        //),
    ],
];

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        'allowedIPs' => ['192.168.220.129','192.168.220.1','::1']
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1', '192.168.220.*','192.168.220.129'] // 按需调整这里
    ];
}

return $config;
